﻿

if (typeof ($) != "undefined") {
    $(document).ready(function () {
        $("#SeqNum").val("1");
        $("#ChartType").val("bar");
        //加载所有菜单信息
        $("#MenuId").find('option').remove();
        var url = "../Extend/AjaxData/jsonlist.aspx?entity=SysFunction&condition=url like 'Extend/Reports/hrChartReportQueryParams.aspx%' order by FunctionPath";
        $.get(url, function (d, s) {
            var list = eval("(" + d + ")");
            if (list.total == 0) {
                //无数据
            }
            else {
                for (var o in list.rows) {
                    var v = list.rows[o].FunctionId;
                    var t = list.rows[o].Name;
                    if (typeof (t) != "undefined") {
                        $("#MenuId").append("<option value='" + v + "' title='" + t + "'>" + t + "</option>");
                    }
                }
                if (getPar(location.href, "id") != "") { //修改时
                    $("#MenuId").attr("value", instance[0].MenuId); //菜单
                    $("#SeqNum").val(instance[0].SeqNum);
                    $("#ChartType").val(instance[0].ChartType);
                    if (instance[0].ChartType == "list") {
                        $("#ChartType").trigger("change");
                    }
                }
            }
        });

        $("#ChartType").change(function () {
            if ($("#ChartType").val() == "list") { //列表类型
                $("#SeqNum").val("1");
                $("#SeqNum").attr("disabled", true);
                $("#ChartTitle").attr("disabled", true);
                $("#Height").attr("disabled", true);
                $("#Width").attr("disabled", true);
                $("#XY").attr("disabled", true);
            }
            else {
                $("#SeqNum").attr("disabled", false);
                $("#ChartTitle").attr("disabled", false);
                $("#Height").attr("disabled", false);
                $("#Width").attr("disabled", false);
                $("#XY").attr("disabled", false);
            }
        });
    });
}

//客户端数据验证
var fnCheckData = function () {
    var funId = $("#MenuId").val();
    if (funId == "" && funId == "undefined") {
        return "请选择模块功能！";
    }
    if ($("#SeqNum").val() == "") {
        return "请输入图表序号！";
    }
    if ($("#SQL").val() == "") {
        return "请输入SQL语句！";
    }
}